package com.cd.cms.common.utils;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URISyntaxException;
import java.util.MissingResourceException;
import java.util.Properties;
import java.util.ResourceBundle;

import org.springframework.stereotype.Service;
public class CommonParam {
	public static String getString(String key) {
    	String ACTIONPATH = "SysConfig.properties";
    	Properties prop = new Properties();
    	String path;
    	FileInputStream  fis =null;
		try {
			path = CommonParam.class.getClassLoader().getResource("").toURI().getPath();
			fis = new FileInputStream(new File(path + ACTIONPATH));
			prop.load(fis);
			if (key == null || key.equals("") || key.equals("null")) {
	            return "";
	        }
	        String result = "";
	        try {
	            result = prop.getProperty(key);
	        } catch (MissingResourceException e) {
	            e.printStackTrace();
	        }
	        return result;
		} catch (Exception e1) {
			e1.printStackTrace();
		}finally{
			try {
				fis.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
    	return null;
    }
    public static void main(String[] args) {
    	String ip =CommonParam.getString("IP");
    	System.out.println(ip);
	}
}
